<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>作用域链</title>
  </head>
  <body>
    <script>
      // 内部函数访问外部函数中的变量采取：就近原则，只能向上访问，当访问到 window 对象即被终止
      var num = 10;

      function fn() {
        var num = 20;

        function fun() {
          console.log('num--', num);
        }
        fun();
      }
      fn();
    </script>
  </body>
</html>
